 <template>
   <el-table
       :cell-style="{'text-align':'center'}"
       :data="feedbackData"
       :header-cell-style="{'text-align':'center'}" border
       row-key="id"
       style="width: 100%">
     <el-table-column width="200" :sortable="true" label="反馈模块" prop="model"/>
     <el-table-column width="200" :sortable="true" label="反馈对象" prop="accountNo"/>
     <el-table-column width="330" :sortable="true" label="反馈内容" prop="content"/>
     <el-table-column width="100" :sortable="true" label="类型" prop="type">
       <template #default="scope">
         <el-tag v-if="scope.row.type === '1'" size="small" type="danger">Bug</el-tag>
         <el-tag v-else-if="scope.row.type === '2'" size="small" type="warning">意见</el-tag>
       </template>
     </el-table-column>
     <el-table-column width="120" :sortable="true" label="状态" prop="feedbackStatus">
       <template #default="scope">
         <el-tag v-if="scope.row.feedbackStatus === '0'" size="small" type="danger">未处理</el-tag>
         <el-tag v-else-if="scope.row.feedbackStatus === '1'" size="small" type="info">已分配待处理</el-tag>
         <el-tag v-else-if="scope.row.feedbackStatus === '2'" size="small" type="success">已处理</el-tag>
       </template>
     </el-table-column>
     <el-table-column width="200" :sortable="true" label="提交时间" prop="createdTime"/>
     <el-table-column width="200" :sortable="true" label="处理时间" prop="handleTime"/>
     <el-table-column width="200" :sortable="true" label="老师反馈" prop="feedbackContent"/>
     <el-table-column class="operate" fixed="right" align="center" label="操作" prop="operate" width="120">
       <template v-slot="scope">
       <el-button
           size="small"
           type="danger"
           @click="deleteById(scope.row)"
       >删除
       </el-button>
         </template>
     </el-table-column>
   </el-table>
   <el-pagination
       class="pagination"
       :page-size="pageSize"
       small
       :pager-count="5"
       :page-sizes="[10, 30 ,  100 , 200]"
       :total="total"
       layout="total, sizes, prev, pager, next"
       @size-change="handleSizeChange"
       @current-change="handleCurrentChange">
   </el-pagination>
 </template>

 <script>
 import request from "@/util/request.js";

 export default {
   name: "FeedbackHandle",
   data() {
     return {
       pageNum: 1,
       pageSize: 10,
       total: 0,
       feedbackData: []
     }
   },
   created() {
     this.getData()
   },
   methods: {
     getData() {
       request.get("/related_feedback/getRelatedByAccountNo?pageNum=" + this.pageNum + "&pageSize=" + this.pageSize + "&accountNo=" + JSON.parse(localStorage.getItem('user')).accountNo).then(res => {
         console.log(res.data)
         if (res.data.code === '200') {
           for (let key in res.data.data) {
             if (key === "records") {
               this.feedbackData = res.data.data[key];
             } else if (key === "total") {
               this.total = res.data.data[key];
             }
           }
           console.log(this.feedbackData)
         }
       })
     },
     handleClick(scope) {
       request.get("/related_feedback/handle?id=" + scope.id).then(() => {
         this.$message({
           type: 'success',
           message: '操作成功!'
         });
         window.location.reload()
       })
     },
     //表尾分页
     handleSizeChange(val) {
       this.pageSize = val;
       this.getData();
     },
     handleCurrentChange(val) {
       this.pageNum = val;
       this.getData();
     },
     deleteById(scope){
       this.$confirm('此操作将永久删除该意见, 是否继续?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
         request.get("/related_feedback/deleteById?id=" +scope.id).then(res =>{
           if(res.data.code === '200'){
             this.$message({
               type: 'success',
               message: '操作成功!'
             })
             location.reload()
           }
         })
       })
     },
   }
 }
 </script>

 <style scoped>

 </style>
